const obj = {
    name: '李四'
}
function test() {
    console.log(this, 'this')  //obj
}
test.bind(obj)()

Function.prototype.myBind = function (obj, ...args) {
    const _this = this
    return function(...data){
        return _this.call(obj,...args,...data)
    }
    
}
function test1(a = 1, b = 2) {
    console.log(a)  //abc
    console.log(b)  //ccc
    console.log(this.a, this.b)  //1 2
}
const obj1 = {
    a: 1,
    b: 2,
}
const result = test1.myBind(obj1, 'abc','ccc')
result('def')


console.log('--------------------------')
const result1 = test1.myBind(obj1, 'abc')
result1('def')

/*
{ name: '李四' } this
abc
ccc
1 2
--------------------------
abc
def
1 2
*/